<include file="User@Public:header"/>
<div class="am-g">
	<div class="am-u-md-3">
		<include file="User@Public:left_menu"/>
	</div>
	<div class="am-u-md-9 am-cf">
		<div class="am-panel am-panel-default am-cf">
			<div class="am-panel-hd">
				<h3 class="am-panel-title">修改资料</h3>
			</div>
			<div class="am-panel-bd">
				<div class="am-tabs">
					<ul class="am-tabs-nav am-nav am-nav-tabs">
						<li <if condition="$tab_hover eq 'base'">class="am-active"</if>><a href="{:U('User/Config/index',array('tab'=>'base'))}">基础设置</a></li>
						<volist name="_tab" id="item">
						<li <if condition="$tab_hover eq 'profile_'.$item['id']">class="am-active"</if>><a href="{:U('User/Config/index',array('tab'=>'profile_'.$item['id']))}">{$item['profile_name']}</a></li>
						</volist>
					</ul>
					<div class="am-tabs-bd">
						<!-- 基础设置 -->
						<div class="am-tab-panel <if condition="$tab_hover eq 'base'">am-active</if>">
							<form class="am-form am-form-horizontal form_base" method="post">
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">用户名：</label>
									<div class="am-u-md-9">
										<input type="text" name="username" readonly="" value="{$data['username']}">
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">昵称：</label>
									<div class="am-u-md-9">
										<input type="text" name="nickname" value="{$data['nickname']}">
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">性别：</label>
									<div class="am-u-md-9">
										<div class="am-btn-group" data-am-button>
											<label class="am-btn am-btn-primary <eq name="data['sex']" value="0">am-active</eq>"><input type="radio" name="sex" value="0">保密</label>
											<label class="am-btn am-btn-primary <eq name="data['sex']" value="1">am-active</eq>"><input type="radio" name="sex" value="1">男</label>
											<label class="am-btn am-btn-primary <eq name="data['sex']" value="2">am-active</eq>"><input type="radio" name="sex" value="2">女</label>
										</div>
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">生日：</label>
									<div class="am-u-md-9">
										<input type="text" name="birthday" value="{$data['birthday']}" placeholder="生日" data-am-datepicker readonly>
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">所在地：</label>
									<div class="am-u-md-9">
										{:hook('J_China_City', array('province'=>$data['pos_province'], 'city'=>$data['pos_city'], 'district'=>$data['pos_district'], 'community'=>$data['pos_community']))}
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">QQ：</label>
									<div class="am-u-md-9">
										<input type="text" name="qq" value="{$data['qq']}">
									</div>
								</div>
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">签名：</label>
									<div class="am-u-md-9">
										<textarea name="signature">{$data['signature']}</textarea>
									</div>
								</div>

								<div class="am-form-group">
									<div class="am-u-md-9 am-u-sm-offset-3">
										<button class="am-btn am-btn-primary submit-btn ajax-post hidden" id="submit" type="submit" target-form="form_base">确 定</button>
										<a class="am-btn am-btn-default btn-return" href="">返 回</a>
									</div>
								</div>
							</form>
						</div>
						<volist name="_tab" id="item">
						<!--{$item['profile_name']}-->
						<div class="am-tab-panel <if condition="$tab_hover eq 'profile_'.$item['id']"> am-active</if>">
							<form class="am-form am-form-horizontal form_{$item['id']}" method="post">
								<volist name="fields[$item['id']]" id="vo">
								<div class="am-form-group">
									<label class="am-u-md-3 am-form-label">{$vo['title']}：</label>
									<div class="am-u-md-9">
										<switch name="vo['type']">
				                            <case value="num">
				                                <input type="text" class="text input-mid" name="{$vo.name}" value="{$data[$vo['name']]}">
				                            </case>
				                            <case value="string">
				                                <input type="text" class="text input-large" name="{$vo.name}" value="{$data[$vo['name']]}">
				                            </case>
				                            <case value="textarea">
				                                <textarea name="{$vo.name}">{$data[$vo['name']]}</textarea>
				                            </case>
				                            <case value="date">
				                                <input type="text" name="{$vo.name}" class="text date" value="{$data[$vo['name']]|date='Y-m-d',###}" placeholder="请选择日期" />
				                            </case>
				                            <case value="datetime">
				                                <input type="text" name="{$vo.name}" class="text time" value="{$data[$vo['name']]|time_format}" placeholder="请选择时间" />
				                            </case>
				                            <case value="bool">
				                                <select name="{$vo.name}">
				                                    <volist name=":parse_field_attr($vo['extra'])" id="v">
				                                        <option value="{$key}" <eq name="data[$vo['name']]" value="$key">selected</eq>>{$v}</option>
				                                    </volist>
				                                </select>
				                            </case>
				                            <case value="select">
				                                <select name="{$vo.name}">
				                                    <volist name=":parse_field_attr($vo['extra'])" id="v">
				                                        <option value="{$key}" <eq name="data[$vo['name']]" value="$key">selected</eq>>{$v}</option>
				                                    </volist>
				                                </select>
				                            </case>
				                            <case value="radio">
				                                <volist name=":parse_field_attr($vo['extra'])" id="v">
				                                	<label class="radio">
				                                    <input type="radio" value="{$key}" name="{$vo.name}" <eq name="data[$vo['name']]" value="$key">checked="checked"</eq>>{$v}
				                                	</label>
				                                </volist>
				                            </case>
				                            <case value="checkbox">
				                                <volist name=":parse_field_attr($vo['extra'])" id="v">
				                                	<label class="checkbox">
				                                    <input type="checkbox" value="{$key}" name="{$vo.name}[]" <if condition="in_array($key,$data[$vo['name']])">checked="checked"</if>>{$v}
				                                	</label>
				                                </volist>
				                            </case>
				                            <case value="editor">
				                                <label class="textarea">
				                                <textarea name="{$vo.name}">{$data[$vo['name']]}</textarea>
				                                {:hook('adminArticleEdit', array('name'=>$vo['name'],'value'=>$data[$vo['name']]))}
				                                </label>
				                            </case>
				                            <case value="picture">
												<input type="file" id="upload_picture_{$vo.name}">
												<input type="hidden" name="{$vo.name}" id="cover_id_{$vo.name}" value="{$data[$vo['name']]}"/>
												<div class="upload-img-box">
												<notempty name="data[$vo['name']]">
													<div class="upload-pre-item"><img src="{$data[$vo['name']]|get_cover='path'}"/></div>
												</notempty>
												</div>
												<script type="text/javascript">
												//上传图片
											    /* 初始化上传插件 */
												$("#upload_picture_{$vo.name}").uploadify({
											        "height"          : 30,
											        "swf"             : "__PUBLIC__/uploadify/uploadify.swf",
											        "fileObjName"     : "download",
											        "buttonText"      : "上传图片",
											        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
											        "width"           : 120,
											        'removeTimeout'	  : 1,
											        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
											        "onUploadSuccess" : uploadPicture{$vo.name},
											        'onFallback' : function() {
											            alert('未检测到兼容版本的Flash.');
											        }
											    });
												function uploadPicture{$vo.name}(file, data){
											    	var data = $.parseJSON(data);
											    	var src = '';
											        if(data.status){
											        	$("#cover_id_{$vo.name}").val(data.id);
											        	src = data.url || '__ROOT__' + data.path
											        	$("#cover_id_{$vo.name}").parent().find('.upload-img-box').html(
											        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
											        	);
											        } else {
											        	updateAlert(data.info);
											        	setTimeout(function(){
											                $('#top-alert').find('button').click();
											                $(that).removeClass('disabled').prop('disabled',false);
											            },1500);
											        }
											    }
												</script>
				                            </case>
				                            <case value="pictures">
											    <input type="file" id="upload_pictures_{$vo.name}">
											    <input type="hidden" name="{$vo.name}" value="{$valStr}" class="icon {$vo.name}" />
											    <div class="upload-img-box">
											        <notempty name="data[$vo['name']]">
											        	<php>
											        	$pictures = explode(',',$data[$vo['name']]);
											        	</php>
											             <volist name="pictures" id="v">
											                <div class="upload-pre-item">
											                    <img src="{$v|get_cover='path'}" data-id="{$v}"/>
											                    <span class='btn-close btn-close-{$vo.name}' title='删除图片'></span>
											                </div>
											             </volist>
											        </notempty>
											    </div>

												<script type="text/javascript">
												    //上传图片
												    $(function(){
												        /* 初始化上传插件*/
												        $("#upload_pictures_{$vo.name}").uploadify({
												            "height"          : 30,
												            "swf"             : "__PUBLIC__/uploadify/uploadify.swf",
												            "fileObjName"     : "download",
												            "buttonText"      : "上传多图",
												            "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
												            "width"           : 120,
												            'removeTimeout'   : 1,
												            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
												            "onUploadSuccess" : uploadPicture{$vo.name},
												            'onFallback' : function() {
												                alert('未检测到兼容版本的Flash.');
												            }
												        });
												        $('.btn-close-{$vo.name}').click(function(event) {
												            event.preventDefault();
												            $(this).parent().remove();
												            picsbox = $("#upload_pictures_{$vo.name}").siblings('.upload-img-box');
												            picArr = [];
												            for (var i = 0; i < picsbox.children().length ; i++) {
												                picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
												            };
												            picStr = picArr.join(',');
												            $('.icon.{$vo.name}').val(picStr);
												        });
												    })
												    function uploadPicture{$vo.name}(file, data){
												        var data = $.parseJSON(data);
												        var src = '';
												        if(data.status){
												            src = data.url || '__ROOT__' + data.path;
												            upload_img = "<div class='upload-pre-item'><img src=" + src +" title='点击显示大图' data-id="+data.id+"> <span class='btn-close btn-close-{$vo.name}' title='删除图片'></span></div>";
												            picsbox = $("#upload_pictures_{$vo.name}").siblings('.upload-img-box');
												            picsbox.append(upload_img)
												            picArr = [];
												            for (var i = 0; i < picsbox.children().length ; i++) {
												                picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
												            };
												            picStr = picArr.join(',');
												            $('.icon.{$vo.name}').val(picStr);
												        } else {
												            updateAlert(data.info);
												            setTimeout(function(){
												                $('#top-alert').find('button').click();
												                $(that).removeClass('disabled').prop('disabled',false);
												            },1500);
												        }
												    }
												</script>
				                            </case>
				                            <case value="file">
												<input type="file" id="upload_file_{$vo.name}">
												<input type="hidden" name="{$vo.name}" value="{:think_encrypt(json_encode(get_table_field($data[$vo['name']],'id','','File')))}"/>
												<div class="upload-img-box">
													<present name="data[$vo['name']]">
														<div class="upload-pre-file"><span class="upload_icon_all"></span>{$data[$vo['name']]|get_table_field=###,'id','name','File'}</div>
													</present>
												</div>
												<script type="text/javascript">
												//上传图片
											    /* 初始化上传插件 */
												$("#upload_file_{$vo.name}").uploadify({
											        "height"          : 30,
											        "swf"             : "__PUBLIC__/uploadify/uploadify.swf",
											        "fileObjName"     : "download",
											        "buttonText"      : "上传附件",
											        "uploader"        : "{:U('File/upload',array('session_id'=>session_id()))}",
											        "width"           : 120,
											        'removeTimeout'	  : 1,
											        "onUploadSuccess" : uploadFile{$vo.name},
											        'onFallback' : function() {
											            alert('未检测到兼容版本的Flash.');
											        }
											    });
												function uploadFile{$vo.name}(file, data){
													var data = $.parseJSON(data);
											        if(data.status){
											        	var name = "{$vo.name}";
											        	$("input[name="+name+"]").val(data.data);
											        	$("input[name="+name+"]").parent().find('.upload-img-box').html(
											        		"<div class=\"upload-pre-file\"><span class=\"upload_icon_all\"></span>" + data.info + "</div>"
											        	);
											        } else {
											        	updateAlert(data.info);
											        	setTimeout(function(){
											                $('#top-alert').find('button').click();
											                $(that).removeClass('disabled').prop('disabled',false);
											            },1500);
											        }
											    }
												</script>
				                            </case>
				                            <default/>
				                            <input type="text" class="text input-large" name="{$vo.name}" value="{$data[$vo['name']]}">
										</switch>
										<div class="am-form-help">{$vo['input_tips']}</div>
									</div>
								</div>
								</volist>

								<div class="am-form-group">
									<div class="am-u-md-9 am-u-sm-offset-3">
										<button class="am-btn am-btn-primary submit-btn ajax-post hidden" id="submit" type="submit" target-form="form_{$item['id']}" url="{:U('User/Config/setuserinfo')}">确 定</button>
										<a class="am-btn am-btn-default btn-return" href="">返 回</a>
									</div>
								</div>
							</form>
						</div>
						</volist>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<include file="User@Public:footer"/>